﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Bimaru
{
    class Grid
    {
        public Cell[, ] Cells { get; set; }
        public int GridSize { get; set; }
        private Random _random;

        public Grid(int gridSize)
        {
            GridSize = gridSize;
            Cells = new Cell[gridSize,gridSize];
            for (int i = 0; i < gridSize; i++)
            {
                for (int j = 0; j < gridSize; j++)
                {
                    Cells[i, j] = new Cell();
                }
            }
        }

        public CellOccupant RotateCell(int x, int y)
        {
            return Cells[x, y].RotateOccupant();
        }

        public int RecommendShipCount
        {
            get { return (GridSize * GridSize) /5; }
        }

        public void PlaceBoats(Ship[] ships)
        {
            _random = new Random((int) (DateTime.Now.Ticks % int.MaxValue));
            bool IsPlaced = false;

            foreach (Ship ship in ships)
            {
                while (!IsPlaced)
                {
                    // Try to place the ship
                    int x = _random.Next(GridSize);
                    int y = _random.Next(GridSize);
                    bool IsVertical = _random.Next(2) == 1;


                    Cell sCell = new Cell(ship.ShipId);


                    

                }
            }
            _random.Next(GridSize);

        }

    }
}